package ru.nsu.expertsystem.chucknorris;

public abstract class AbstractWhoWhomPredicate implements Predicate {
	private Person who;
	private Person whom;
	
	public AbstractWhoWhomPredicate() {
		this.who = null;
		this.whom = null;
	}
	
	public AbstractWhoWhomPredicate(Person who, Person whom) {
		this.setWho(who);
		this.setWhom(whom);
	}	
	
	/**
	 * @return the who
	 */
	public Person getWho() {
		return who;
	}

	/**
	 * @param who the who to set
	 */
	public void setWho(Person who) {
		this.who = who;
	}

	/**
	 * @return the whom
	 */
	public Person getWhom() {
		return whom;
	}

	/**
	 * @param whom the whom to set
	 */
	public void setWhom(Person whom) {
		this.whom = whom;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((who == null) ? 0 : who.hashCode());
		result = prime * result + ((whom == null) ? 0 : whom.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(java.lang.Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AbstractWhoWhomPredicate other = (AbstractWhoWhomPredicate) obj;
		if (who == null) {
			if (other.who != null)
				return false;
		} else if (!who.equals(other.who))
			return false;
		if (whom == null) {
			if (other.whom != null)
				return false;
		} else if (!whom.equals(other.whom))
			return false;
		return true;
	}

}
